home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 749 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.8 KB

  1. From: jpotter@falcon.lhup.edu (John E. Potter)
  2. Message-ID: <4if8u9$6lf@jake.esu.edu>
  3. X-Original-Date: 16 Mar 1996 20:39:37 GMT
  4. Path: in2.uu.net!bounce-back
  5. Date: 17 Mar 96 03:59:27 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Template instantiation
  9. Organization: East Stroudsburg University, Pennsylvania
  10. X-Newsreader: TIN [version 1.2 PL2]
  11. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  12.     iQBFAgUBMUuOJ+EDnX0m9pzZAQGBbAF8DlgVvdb19Rq9iOUPCDb80L0FhUFfNBMN
  13.     VUuXwY5qS8wzv5i3GXU6UQwBavy5DTMG
  14.     =gaDP
  15.  
  16. I have only found one compiler which accepts the following.  The others
  17. attempt to instantiate class N prior to completing class L.  As I read
  18. DWP-14.3 [temp.inst], class N<int> should not be instantiated in the
  19. following code.  It would be instantiated when some class L<int> function
  20. used an N<int>.
  21.  
  22. template <class T> class N;
  23. template <class T> class L {
  24.     public :
  25.         // ...
  26.     private :
  27.         N<T>* ptr;
  28.     };
  29. template <class T> class N {
  30.     private :
  31.         N (T, const L<T>&);
  32.         L<T> next;  // error L<int> incomplete type, size unknown
  33.         T data;
  34.         friend class L<T>;
  35.     };
  36. int main () {
  37.     L<int> l;
  38.     }
  39.  
  40. Do I have one correct compiler that accepts it, several correct compilers
  41. which reject it, or (I hope not) all correct compilers because it is not
  42. specified?
  43.  
  44. If the latter, is there any standard way to make this portable.  I can
  45. change ptr to a void* and reinterpret_castrate everything, but that is
  46. not very pleasing.
  47.  
  48. Thanks,
  49. John
  50. ---
  51. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  52. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  53. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  54. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  55. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  56.